package com.xt.website.controller;

import com.xt.website.po.Product;
import com.xt.website.po.ProductExt;
import com.xt.website.po.ProductFile;
import com.xt.website.service.ProductService;
import com.xt.website.util.MyPageInfo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: jiangyu
 * @Date: 2019/8/18 14:02
 * @Description:
 */
@RestController
@RequestMapping("/product")
public class ProductController {

    @Resource
    private ProductService productService;

    /**
     * 根据一级类目，查询的产品
     */
    @RequestMapping("/findProductsByCid")
    public MyPageInfo<Product> findProductsByCid(Integer pageNow, Integer cid, Integer pageSize) {
        return productService.findProductsByCid(pageNow, cid, pageSize);
    }

    /**
     * 根据二级类目，查询的产品
     */
    @RequestMapping("/findProductsByCsid")
    public MyPageInfo<Product> findProductsByCsid(int pageNow, int csid) {
        return productService.findProductsByCsid(pageNow, csid);
    }

    /**
     * 查看商品详情
     */
    @RequestMapping("/productDetails")
    public ProductExt<ProductFile> productDetails(Integer pid) {
        return productService.productDetails(pid);
    }
}
